#include <stdio.h>

void display(const char *s, int len)
{
	int i,j;
	for (i = 0; i < len; i++) {
		for (j=0; j<8; ++j) {
			printf("%01d", s[i]>>(7-j)&0x1);
		}
		printf(" ");
	}
	printf("\n");
}

int test(const char *s, char *d, int len)
{
	int i,j;
	for (i = 0; i < len; i++) {
		for (j = 0; j < 8; j++) {
			d[i] |= (s[i]>>(7-j)&0x1)<<j;
		}
	}
}

int main(int argc, char const* argv[])
{
	char s[3] = {9, 5, 27};
	char d[3] = {0};
	display(s, 3);
	test(s, d, 3);
	display(d, 3);
	return 0;
}
